/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
// 
function twoSum(nums, sum) {
    if (nums.length < 2) {
        return []
    }
    let map = new Map();
    for (let i = 0; i < nums.length; i++) {
        if (map.get(sum - nums[i]) === undefined) {
            map.set(nums[i], i)
        } else {
            return [i, map.get(sum - nums[i])]
        }
    }
}

function twoSum(nums, sum) {
    if (nums.length < 2) {
        return []
    }
    for (let i = 0; i < nums.length; i++) {
        for (let j = i+1; j < nums.length; j++) {
            if(nums[i]+nums[j] === sum){
                return [i,j]
            }
        }
    }
}